from minio import Minio
from minio.error import S3Error
def FHmain(asiaphotosNAME,DIR):
    # Create a client with the MinIO server playground, its access key
    # and secret key.
    client = Minio(
        "fotdev.s3.fr-par.scw.cloud:443",
        access_key="SCWZEGS96EPSN322YAQR",
        secret_key="2437e432-5460-4509-b98d-1dc2a0bcac6d",
        region="fr-par",
        secure=True,
    )

    # Make 'asiatrip' bucket if not exist.
    found = client.bucket_exists("crmwf")
    if not found:
        client.make_bucket("crmwf")
    else:
        print("Bucket 'crmwf' already exists")

    client.fput_object(
        "crmwf", asiaphotosNAME, DIR+"/"+asiaphotosNAME,
    )
    print("successfully uploaded")
def FHmaintry(asiaphotosNAME,DIR):
    try:
        FHmain(asiaphotosNAME,DIR)
    except S3Error as exc:
        print("error occurred.", exc)